<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE topic
  PUBLIC "-//OASIS//DTD DITA Composite//EN" "ditabase.dtd">
<topic id="topic1" xml:lang="en">
  <title id="hm149825">pg_rewrite</title>
  <body>
    <p>The <codeph>pg_rewrite</codeph> system catalog table stores rewrite rules for tables and
      views. <codeph>pg_class.relhasrules</codeph> must be true if a table has any rules in this
      catalog.</p>
    <table id="hm149830">
      <title>pg_catalog.pg_rewrite</title>
      <tgroup cols="4">
        <colspec colnum="1" colname="col1" colwidth="131pt"/>
        <colspec colnum="2" colname="col2" colwidth="86pt"/>
        <colspec colnum="3" colname="col3" colwidth="85pt"/>
        <colspec colnum="4" colname="col4" colwidth="147pt"/>
        <thead>
          <row>
            <entry colname="col1">column</entry>
            <entry colname="col2">type</entry>
            <entry colname="col3">references</entry>
            <entry colname="col4">description</entry>
          </row>
        </thead>
        <tbody>
          <row>
            <entry>rulename</entry>
            <entry>name</entry>
            <entry> </entry>
            <entry>Rule name.</entry>
          </row>
          <row>
            <entry>ev_class</entry>
            <entry>oid</entry>
            <entry>pg_class.oid</entry>
            <entry>The table this rule is for.</entry>
          </row>
          <row>
            <entry>ev_type</entry>
            <entry>char</entry>
            <entry> </entry>
            <entry>Event type that the rule is for: 1 = SELECT, 2 = UPDATE, 3 = INSERT, 4 =
              DELETE</entry>
          </row>
          <row>
            <entry>ev_enabled</entry>
            <entry>char</entry>
            <entry> </entry>
            <entry>Controls in which session replication role mode the rule fires. Always O, rule
              fires in origin mode.</entry>
          </row>
          <row>
            <entry>is_instead</entry>
            <entry>bool</entry>
            <entry> </entry>
            <entry>True if the rule is an <codeph>INSTEAD</codeph> rule</entry>
          </row>
          <row>
            <entry>ev_qual</entry>
            <entry>pg_node_tree</entry>
            <entry> </entry>
            <entry>Expression tree (in the form of a <codeph>nodeToString()</codeph> representation)
              for the rule's qualifying condition</entry>
          </row>
          <row>
            <entry>ev_action</entry>
            <entry>pg_node_tree</entry>
            <entry> </entry>
            <entry>Query tree (in the form of a <codeph>nodeToString()</codeph> representation) for
              the rule's action</entry>
          </row>
        </tbody>
      </tgroup>
    </table>
  </body>
</topic>
